package cn.rongdao.jrkabao.ui.deposit.adapter;

import android.view.View;
import android.widget.TextView;

import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerViewHolder;
import com.mifengkong.frtools.util.FRCollection;
import com.mifengkong.frtools.util.FRString;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.deposit.IncomeAndExpenditureBean;
import cn.rongdao.jrkabao.util.NumberUtil;

/**
 * Created by jack on 2017/7/27
 */

public class IncomeAndExpenditureViewHolder extends FRBaseRecyclerViewHolder<IncomeAndExpenditureBean> {

    private TextView tvTime;
    private TextView tvMoney;
    private TextView tvCard;


    public IncomeAndExpenditureViewHolder(View view) {
        super(view);
        tvTime = findView(R.id.iiae_tv_time);
        tvMoney = findView(R.id.iiae_tv_money);
        tvCard = findView(R.id.iiae_tv_card);
    }

    @Override
    protected void onItemDataUpdated(IncomeAndExpenditureBean data) {
        tvTime.setText(data.getDate());
        if (FRString.isEmpty(data.getBankcard())) {
            tvMoney.setText(FRCollection.appendAsString("+", NumberUtil.getTwoDecimalPlaces(data.getAmount()), "元", ""));
            tvCard.setText(data.getTip());
        } else {
            tvMoney.setText(FRCollection.appendAsString("-", NumberUtil.getTwoDecimalPlaces(data.getAmount()), "元", ""));
            tvCard.setText(FRCollection.appendAsString("收款卡：", data.getBankcard(), ""));
        }
    }
}
